package com.itheima.controller;


import com.itheima.exception.BusinessException;
import com.itheima.utile.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class ProjectExceptionAdvice {

    @ExceptionHandler(BusinessException.class)
    public Result doBusinessException(BusinessException ex){
        return new Result(ex.getCode(),ex.getCause());
    }

//    @ExceptionHandler(Exception.class)
//    public Result exception(Exception e){
//        return new Result(e.getMessage(),e.getCause());
//    }
}
